home *** CD-ROM | disk | FTP | other *** search
/ Merciful 2 / Merciful - Disc 2.iso / software / d / designerv1.53pseudoreg.lha / Designer / PubScreenDemo / PubScreenDemoP1.c < prev    next >
C/C++ Source or Header  |  1995-04-28  |  2KB  |  87 lines

  1. /* Compile me to get full executable. */
  2.  
  3. #include <stdio.h>
  4. #include "pubscreendemop1win.c"
  5.  
  6.  
  7. int main(void)
  8. {
  9. int done=0;
  10. ULONG class;
  11. UWORD code;
  12. struct Gadget *pgsel;
  13. struct IntuiMessage *imsg;
  14. struct Screen *Scr=NULL;
  15. if (OpenLibs()==0)
  16.     {
  17.     Scr = OpenMyPubScrScreen();
  18.     PubScreenStatus(Scr,0);
  19.     if (Scr != NULL)
  20.         {
  21.         if (OpenWindowScrWin(Scr)==0)
  22.             {
  23.             while(done==0)
  24.                 {
  25.                 Wait(1L << ScrWin->UserPort->mp_SigBit);
  26.                 imsg=GT_GetIMsg(ScrWin->UserPort);
  27.                 while (imsg != NULL )
  28.                     {
  29.                     class=imsg->Class;
  30.                     code=imsg->Code;
  31.                     pgsel=(struct Gadget *)imsg->IAddress; /* Only reference if it is a gadget message */
  32.                     GT_ReplyIMsg(imsg);
  33.                     if (class==IDCMP_CLOSEWINDOW)
  34.                         {
  35.                         CloseWindowScrWin();
  36.                         if (CloseScreen(Scr))
  37.                              {
  38.                             Scr=NULL;
  39.                             done=1;
  40.                             }
  41.                         else
  42.                             {
  43.                             OpenWindowScrWin(Scr);
  44.                             if (ScrWin==NULL)
  45.                                 {
  46.                                 done=1;
  47.                                 printf("Could not reopen window.\n");
  48.                                 }
  49.                             }
  50.                         }
  51.                     if (class==IDCMP_REFRESHWINDOW)
  52.                         {
  53.                         GT_BeginRefresh(ScrWin);
  54.                         GT_EndRefresh(ScrWin, TRUE);
  55.                         }
  56.                     if (class==IDCMP_GADGETUP)
  57.                         {
  58.                         if (pgsel->GadgetID == State)
  59.                             {
  60.                             if (code==0)
  61.                                 PubScreenStatus(Scr,0);
  62.                             else
  63.                                 PubScreenStatus(Scr,0);
  64.                             }
  65.                         }
  66.                     imsg = NULL;
  67.                     if (ScrWin != NULL)
  68.                         imsg=GT_GetIMsg(ScrWin->UserPort);
  69.                     }
  70.                 }
  71.             
  72.             if (ScrWin != NULL)
  73.                 CloseWindowScrWin();
  74.             }
  75.         else
  76.             printf("Cannot open window.\n");
  77.         if (Scr != NULL)
  78.             CloseScreen(Scr);
  79.         }
  80.     else
  81.         printf("Cannot Open Screen.\n");
  82.     CloseLibs();
  83.     }
  84. else
  85.     printf("Cannot open libraries.\n");
  86. }
  87.